﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ServicesSheet_StockManage : System.Web.UI.Page
{
    private Srvtools.WebDataSet WMaster;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitializeComponent();

            Master.DataSource = WMaster;


            MasterPage_MasterPage master = (MasterPage_MasterPage)this.Page.Master;
            master.HelpHref = "~/Help/ServicesSheet/办公用品入库管理.htm";
            master.PageName = "办公用品入库管理";
            master.PicUrl = "";
            master.IntiBar();
        }
    }

    private void InitializeComponent()
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ServicesSheet_StockManage));
        this.WMaster = new Srvtools.WebDataSet();
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).BeginInit();
        // 
        // WMaster
        // 
        this.WMaster.Active = true;
        this.WMaster.AlwaysClose = false;
        this.WMaster.DeleteIncomplete = true;
        this.WMaster.Guid = null;
        this.WMaster.LastKeyValues = null;
        this.WMaster.Locale = new System.Globalization.CultureInfo("zh-CN");
        this.WMaster.PacketRecords = 100;
        this.WMaster.Position = -1;
        this.WMaster.SetWhere("Services_OfficeSupplies_Stock.Operate=1");
        this.WMaster.RemoteName = "ServiceSheet.Services_OfficeSupplies_Stock";
        this.WMaster.ServerModify = true;
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).EndInit();
    }

    protected string GetEmployeeId()
    {
        String str = Srvtools.CliUtils.GetValue("_UserCode")[1].ToString();
        str = int.Parse(str).ToString();
        return str;
    }

    protected object GetNowDate()
    {
        return DateTime.Now.ToString();
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string Sql = "";
        if (QuerySId.BindingValue.Length > 0) Sql = Sql + " (Services_OfficeSupplies_Stock.SId = " + QuerySId.BindingValue + ") ";
        string Ast = (Sql.Length == 0) ? "" : "and";
        if (WebDropDownList1.SelectedValue != "")
            Sql = Sql + Ast + " (Services_SV_Supplies_SV_Type.TId =  " + WebDropDownList1.SelectedValue + " ) ";
        string Ast2 = (Sql.Length == 0) ? "" : "and";
        if (NdYear.SelectedValue != "0")
            Sql = Sql + Ast2 + string.Format(" (YEAR(Services_OfficeSupplies_Stock.OpeDate) = {0})  and (MONTH(Services_OfficeSupplies_Stock.OpeDate) = {1})  ", NdYear.SelectedValue, NMonth.SelectedValue);
        if (Sql != "")
            Sql += " AND Services_OfficeSupplies_Stock.Operate=1";
        else
            Sql += "Services_OfficeSupplies_Stock.Operate=1";
        Master.SetWhere(Sql);
        wgvMaster.DataBind();
    }

    protected void btnClear_Click(object sender, EventArgs e)
    {
        WebDropDownList1.SelectedValue = "";
        QuerySId.BindingValue = "";
        NdYear.SelectedValue = "0";

        string Sql = "Services_OfficeSupplies_Stock.Operate=1";
        Master.SetWhere(Sql);
        wgvMaster.DataBind();
    }
}
